//
//  OwlSplitRightPartViewController.m
//  Owl
//
//  Created by Tianzhou on 09-2-21.
//  Copyright 2009 Tianzhou Software Inc.. All rights reserved.
//

#import "OwlSplitRightPartViewController.h"
#import "OwlTableViewController.h"
#import "OwlWindowController.h"

@implementation OwlSplitRightPartViewController

@synthesize tableViewAdded = isTableViewAdded_;

- (id)initWithNibName:(NSString *)name bundle:(NSBundle *)bundle windowController:(OwlWindowController *)windowController
{
	if (![super initWithNibName:name bundle:bundle windowController:windowController])
		return nil;
	[self setRepresentedObject:[windowController document]];
	tableViewController_ = [[OwlTableViewController alloc] initWithNibName:@"TableView" bundle:nil windowController:windowController];
	[self addChild:tableViewController_];
	isTableViewAdded_ = YES;
	return self;
}

- (void)dealloc
{
	[tableViewController_ release];
	[super dealloc];
}

- (void)awakeFromNib
{
	[self.view addSubview:[[self.children objectAtIndex:0] view]];
	
	// make sure the embeded view is the same size as the containing view
	[[[self.children objectAtIndex:0] view] setFrame:[self.view bounds]];
	
//	self.view.subviews = [NSArray arrayWithObjects:[[self.children objectAtIndex:0] view],[[self.children objectAtIndex:1] view],nil];
//	[[[self.children objectAtIndex:0] sourceListController] addObserver:self
//															 forKeyPath:@"selectedObjects"
//																options:NSKeyValueObservingOptionNew
//																context:nil];
}

//- (void)respondToSourceListNewSelection:(id)newSelection
//{
//	if (isTableViewAdded_)
//	{ 
//		if ([tableViewController_ conformsToProtocol:@protocol(OwlSourceListViewProtocol)])
//		{
//			[tableViewController_ respondToSourceListNewSelection:newSelection];
//		}
//	}
//}

@end
